<?php
// +----------------------------------------------------------------------
// | 青航系统 [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2023-永久 https://www.feifeiyu.club/ All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 青航-不吃芒果 <1716892803@qq.com>
// +----------------------------------------------------------------------
namespace app\admin\controller;
use think\exception\Jump;
use think\facade\View;
class Grmesge extends  Common{
    
    
    // 数据列表
    public function groupid_message() {
    	$list = D('msg')->where(['issystem'=>1])->order('messageid ASC')->paginate(15);
    	return view('message/message_groupid',['list'=>$list]);
    }
    
    // 添加数据 
    public function add() {
    	$list = D('group')->field('groupid,name')->select();
    	if (request()->isPost()) {
    	    if(!input('post.content'))Jump::error('内容不能为空!'); 
    	    $k['message_time'] = time();
            $k['subject'] = str_cut(input('post.content'),50);
            $k['send_from'] = 1;
            $k['groupid'] = input('post.groupid');
            $k['status'] = 1;
            $k['content'] = input('post.content');
            $k['send_to'] = '';
            $k['issystem'] = 1;
            $r = D('msg')->insert($k);
             // 判断是否执行成功
            if($r){
    		   Jump::success('发送成功!'); 
    		}
    		else {
    		    Jump::error('发送失败!'); 
    		}
    		
    	}
    	sleep(1);
    	return view('message/groupid_message_add',['list'=>$list]);
    }
    
    
    
    
    // 多选删除
    public function dels() {
    	if (request()->isPost()) {
    	    // 判断是否获取到值
    		if(!input('param.fx'))Jump::error('没有选择项目!!');
    		// 再循环提交过来的值
    		foreach(input('param.fx') as $id) {
               $r = D('msg')->where('messageid',$id)->delete();  
            }
         }
    	// 判断是否执行成功
    	if($r) {
    		Jump::success('删除成功!');
    	} else {
    		Jump::error('删除失败!');
    	}
    }  
    
    
}